---
layout: "default"
title: "withUnsafeMutablePointer"
description: "Swift documentation for 'withUnsafeMutablePointer': Invokes body with an UnsafeMutablePointer to arg and returns the."
keywords: "withUnsafeMutablePointer,func,swift,documentation"
root: "/v3.0"
---

<div class="declaration" id="func-withunsafemutablepointer-t-result-to_-inout-t_-unsafemutablepointer-t-throws-result">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-withunsafemutablepointer-t-result-to_-inout-t_-unsafemutablepointer-t-throws-result">func withUnsafeMutablePointer&lt;T, Result&gt;(<wbr>to:<wbr> inout T, _: (UnsafeMutablePointer&lt;T&gt;) throws -&gt; Result)</a>
        
<div class="comment collapse" id="comment-func-withunsafemutablepointer-t-result-to_-inout-t_-unsafemutablepointer-t-throws-result"><div class="p">
    <p>Invokes <code>body</code> with an <code>UnsafeMutablePointer</code> to <code>arg</code> and returns the
result. Useful for calling Objective-C APIs that take &quot;in/out&quot;
parameters (and default-constructible &quot;out&quot; parameters) by pointer.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func withUnsafeMutablePointer&lt;T, Result&gt;(to arg: inout T, _ body: (UnsafeMutablePointer&lt;T&gt;) throws -&gt; Result) rethrows -&gt; Result</code>
    
    
</div></div>
</div>
